import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { ProductVariant } from '../domain';

@Injectable({ providedIn: 'root' })
export class OrderService {
  constructor(private http: HttpClient) {}

  geeProductVariantsByProductId(
    productId: string
  ): Observable<ProductVariant[]> {
    return this.http.get<ProductVariant[]>(
      `${environment.baseUrl}/productVariants`,
      {
        params: {
          _expand: 'product',
          _embed: 'productVariantImages',
          productId,
        },
      }
    );
  }
}
